package com.duoketech.service.weixin.product;

import com.duoketech.model.product.Product;
import com.jfinal.plugin.activerecord.Page;

public class WxProductService {
    public static WxProductService ME = new WxProductService();
    public Page<Product> queryProduct(int pageNum,int pageSize){
        String sql=" from "+Product.dao.tableName()+" where status=? and is_sale=? order by id desc";
        Page<Product> productPage = Product.dao.paginate(pageNum,pageSize,"select * ",sql,Product.STATUS_NORMAL,Product.SALE_YES);
        for(Product p: productPage.getList()){
            p.set(Product.PRICE,p.price());
            p.set(Product.IS_POST,p.is_post());
        }
        return productPage;
    }

    public Product queryProduct(int productId){

        return Product.dao.findById(productId);
    }
}
